package com.huang.base.core;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 转换类
 * @param <FROM>
 * @param <TO>
 */
public abstract class BaseConvertor<FROM,TO> {

    public abstract TO doConvert(FROM m);

    public List<TO> batchConvert(List<FROM> mList) {
        return mList.stream().map(this::doConvert).collect(Collectors.toList());
    }

    public Set<TO> batchConvert(Set<FROM> mSet){
        return mSet.stream().map(this::doConvert).collect(Collectors.toSet());
    }
}
